# -*- coding: utf-8 -*-
# @Time    : 2024/1/6  20:34
# @Author  : zhanghao
# @FileName: logger.py
# @Software: PyCharm
"""
    Description: 日志模块
"""
import os

from loguru import logger


class Logger:
    flag = True
    logger = logger

    @staticmethod
    def init():
        if Logger.flag:
            BASE_DIR = 'D:/loginoa'
            Logger.logger.add(os.path.join(BASE_DIR, "./logs/{time:YYYY-MM-DD}.log"),
                              format="{time: YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
                              rotation="00:00", retention=3, encoding='utf-8')
            Logger.flag = False

    @staticmethod
    def get():
        if Logger.flag:
            Logger.init()
        return Logger.logger
